<div class="row">
                <div class="col-md-12">
                     Advanced Tables -->
                    <div class="panel panel-defaultpq">
                        <div class="panel-heading">
                           Purchase requisition Listing
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">

   <?php if($_SESSION['delmsg']!="")
          {?>
            <div class="col-md-6">
            <div class="alert alert-success" >
            <strong>Success :</strong> 
            <?php echo htmlentities($_SESSION['delmsg']);?>
            <?php echo htmlentities($_SESSION['delmsg']="");?>
            </div>
            </div>
    <?php } ?>

</div>

<section id="table">                           
    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr class="tableheader" >
                                            <th>SL</th>
                                            <th>Requisition NO</th>
                                            <th>Item Code</th>
                                            <th>Vendor name</th>
                                            <th>Item name</th>
                                            <th>quantity</th>
                                            <th>Unit</th>
                                            <th>Price</th>
                                            <th>Total Amount</th>
					                        <th>Warehouse</th>
                                            <th>create date</th>
                                            <th>update date</th>
                                            <th>Status</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
            <?php
            //$con = mysqli_connect("localhost", "root", "", "suncrops_inventory"); 
            try {
           $dbh = new PDO("mysql:host=localhost;dbname=suncrops_inventory", "root", "");
           $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            } catch (PDOException $e) {
            die("Connection Failed: " . $e->getMessage());
            }

            $sql = "SELECT T0.id_item,T0.itemid, T2.vendorname ,T1.item_name,T0.quantity,T0.unit ,T0.itemprice ,T0.total, T0.regdate,T0.updatetime,T0.id_branch,T0.status
                    FROM purchase_req T0 
                    Left join item_masterdata T1 on T0.itemid=T1.id 
                    Left join vendor T2 on T0.idvendor=T2.id_vendor "; 
                   
            $query = $dbh->prepare($sql);
            $query->execute();   
            $results=$query->fetchAll(PDO::FETCH_OBJ);
            $cnt=1;
            if ($query->rowcount() > 0)

            {
              foreach($results as $result)  
              { ?>
                  <tr class="odd gradex"> 
                        
                          <td class="center"><?php echo htmlentities($cnt);?></td>
                          <td class="center"><?php echo htmlentities($result->id_item);?></td>
                          <td class="center"><?php echo htmlentities($result->itemid);?></td>
                          <td class="center"><?php echo htmlentities($result->vendorname);?></td>
                          <td class="center"><?php echo htmlentities($result->item_name);?></td>
                          <td class="center"><?php echo htmlentities($result->quantity);?></td>
                          <td class="center"><?php echo htmlentities($result->unit);?></td>
                          <td class="center"><?php echo htmlentities($result->itemprice);?></td>
                          <td class="center"><?php echo htmlentities($result->total);?></td>
 			  <td class="center"><?php echo htmlentities($result->id_branch);?></td>
                          <td class="center"><?php echo htmlentities(date("Y-m-d", strtotime($result->regdate)));?></td>
                          <td class="center"><?php echo htmlentities(date("Y-m-d",strtotime($result->updatetime)));?></td>              
                          <td <?php $stats=$result->status;
                                    if($stats==1){
                                             ?>
                                                 <span style="color: green">Approved</span>
                                                 <?php } if($stats==2)  { ?>
                                                <span style="color: red">Not Approved</span>
                                                 <?php } if($stats==0)  { ?>
                         <span style="color: blue">waiting for approval</span>
                         <?php } ?>
                        </td>
                          <td  class="center">
                           <a href="edit_price_quotation.php?pqreqid=<?php echo htmlentities($result->id_item);?>"><button class="btn btn-primary"><i class="fa fa-edit "></i> Edit</button> 
                            <a href="manage_pquotation.php?reqdel=<?php echo htmlentities($result->id_item);?>" onclick="return confirm('Are you sure you want to delete?');"" >  <button class="btn btn-danger"><i class="fa fa-pencil"></i> Delete</button>
                          </td>
                  </tr>
  <?php $cnt=$cnt+1;}}?> 
          </tbody>
        </table>
</section>
           
    </div>
    </div>